package com.stone.design.mode.command;

/**
 * 抽象命令
 *
 * @author Mr_wenpan@163.com 2022/01/16 14:03
 */
public abstract class Command {

    /**
     * 将命令接收者实现枚举到父类，子类可以直接使用
     */
    protected CommandReceiver defaultReceiverA = new ConcreteCommandReceiverA();
    protected CommandReceiver defaultReceiverB = new ConcreteCommandReceiverB();

    /**
     * 仅子类可见，命令接受者(如果这里有多个命令接受者，那么这里可以使用集合)
     */
    protected final CommandReceiver commandReceiver;

    /**
     * 每个命令都必须要有命令接受者，所以将命令接收者提取到公共父类
     */
    public Command(CommandReceiver commandReceiver) {
        this.commandReceiver = commandReceiver;
    }

    /**
     * 每个命令都必须要有一个执行命令的方法
     */
    public abstract void execute();
}
